package com.hp.appfw.util;


import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;



public class SpringUtil {
	private static BeanFactory beanFactory = null;
	private static final String SPRING_CFG = "applicationContext.xml";

	public static synchronized BeanFactory getBeanFactory() {
		if (beanFactory == null) {
			beanFactory = new ClassPathXmlApplicationContext(SPRING_CFG);
		}
		return beanFactory;
	}

	public static Object getBean(String beanName) throws NullPointerException {
		if (beanName == null) {
			throw new java.lang.NullPointerException("Bean name can't be null.");
		}
		return getBeanFactory().getBean(beanName);
	}
}
